All Questions
Tagged with coding-stylenaming
46 questions
1vote
2answers
267views
What is an appropriate length for function names? [closed]
I'm writing a C++ class, CBookSpellDef which has the following methods: int GetIndexOf(const char *psz); char* GetNameAtIndex(int index) { return m_spellTypes[index].szName; } char* ...
0votes
4answers
409views
Are "easier to search for the interface" and "avoid yo-yo to interface to find implementations to fix bugs" reasons to add prefix "I" on interfaces?
According to Should interface names begin with an "I" prefix?, I should not add prefix "I" to interfaces. However, I think prefix "I" in interface may be useful sometimes....
0votes
2answers
160views
Is usage of "with" prefix acceptable for filter methods that are specific(not generic) [closed]
I am not a native english speaker so I have the following question related to naming I have a class that has generic filter method of type: filter(Predicate predicate) In the same class I have some ...
-1votes
1answer
3kviews
Best practices for naming python utils / extending core modules?
So a lot of the time my utils end up with a structure that mirrors the core library. I might end up writing a multiline version of str.center, an itertools-y function that returns the first or last ...
9votes
2answers
1kviews
Should function names describe their parameter types?
If you wish to perform the same action using different parameters, you can either make differently named functions: public Apple findAppleById(long id){ return repo.findById(id); } public Apple ...
0votes
2answers
306views
Which approaches are exists for using of possessive case in variables/classes/methods naming?
In variables/classes/methods naming, sometimes "of" preposition is omitted and word order changing, for example: "Absolute path of source file of entry point" -> "...
23votes
3answers
8kviews
Why are module-specific prefixes widely used for function names in C modules?
In some C projects, function names start with a common prefix indicative of the module name, for example: mymodule_do_this_stuff(); mymodule_do_that_stuff(); Is there a justification for doing so ...
4votes
4answers
1kviews
Is a constant name related to its current value an anti-pattern? [closed]
For example, suppose I have a string constant like this: const TITLEBAR_MESSAGE="Welcome back, %USERNAME%!"; I think it is more readable when it is named as const WELCOME_BACK_USERNAME="Welcome ...
2votes
1answer
2kviews
Should "Impl" naming always be avoided?
When implementing interfaces, as a general rule, Impl is evil. Ok, but is it evil in the following case? I've a service that has (and probably will have) only one implementation. In such case, ...
1vote
2answers
2kviews
Using "On" at the start of a method name
From what I've observed, methods that start with the word "On" fall into two categories: A base class that defines an event will expose a protected method whose name starts with "On" followed by the ...
0votes
2answers
145views
Nomenclature for object inspection functionality
I'm adding mod support for a game I'm working on. I parse a data file that looks something like this: "requirements": { "is_class": { "class": "warrior" }, "is_in_faction": { "faction": "...
5votes
3answers
9kviews
Is it necessary for a boolean to be "false" by default?
For example, to store whether sound is on, I have a boolean originally named "isSoundOn": private boolean isSoundOn=true; however, the default value of boolean is false, but I want my application to ...
6votes
1answer
862views
Is method with "ByXXX" suffix (eg:findUserById) redundant?
Sometimes I can see method definition like: public User findUserById(int id){ } But my justification is, isn't "(int id)" already include the information of "ById"? is it better to have naming just ...
-1votes
1answer
189views
For use once only functions extracted from a longer function, should the name be xxx1(),xxx2,... or relate to its task?
According to Is it OK to split long functions and methods into smaller ones even though they won't be called by anything else?, I should split long functions into smaller functions even if they ...
3votes
1answer
151views
Should I avoid creating a variable with shorter name for a constant?
suppose I have code like this someFunction:function(userId){ var url=SomeClass.SomeNetworkConnector.SOME_URL; if(url !== undefined && userId !== undefined){ this.openURL(url+"?userid="...